

#include "ArrayShm.h"

ArrayShm::ArrayShm()
{

}
ArrayShm::~ArrayShm()
{

}
bool ArrayShm::init(const char * pcFileName, QMode eMode)
{
    bool bStat = Shm::init(pcFileName,eMode);
    if (false == bStat)
    {
        return bStat;
    }    
    return bStat;
}
void* ArrayShm::GetBlock(size_t nReQSize,int index )
{
    void* vRet = NULL;
    vRet = (void*) ((char*)m_pBuf + (index) * nReQSize);
    return vRet;
}

bool ArrayShm::PutValue(Data& dt,int index)
{
    void* pdt = GetBlock(sizeof(Data),index);
    if (NULL != pdt)
    {
        memcpy(pdt, &dt, sizeof(Data));
        return true;
    }
    return false;
}
bool ArrayShm::GetValue(Data& dt,int index)
{
    void* pdt = GetBlock(sizeof(Data),index);
    if (NULL != pdt)
    {
        memcpy(&dt, pdt, sizeof(Data));
        return true;
    }
    return false;
}

int  ArrayShm::size()
{
    return m_nElemCount;
}
